package edu.udo.sopra10.chaturaji.ai;

import edu.udo.sopra10.chaturaji.entities.*;
import edu.udo.sopra10.chaturaji.entities.coordinates.Position;
import edu.udo.sopra10.chaturaji.entities.pieces.Piece;
import edu.udo.sopra10.chaturaji.entities.transfer.DiceRoll;
import edu.udo.sopra10.chaturaji.entities.transfer.DiceRoll.EquivalenceClass;

public class AIMoveTree {
	private static AIMoveTree instance = new AIMoveTree();
	
	private AIMoveTreeAbstract aiMoveTreeRoot;
	
	private Player currentPlayer;
	
	private AIMoveTree() {
		aiMoveTreeRoot = new AIMoveTreeRoot();
		addDiceChildren(aiMoveTreeRoot);
	}
	
	public static AIMoveTree getInstance(){
		return instance;
	}

	public AIMoveTreeAbstract getRoot(){
		return aiMoveTreeRoot;
	}
	
	private void deleteDiceChildren(DiceRoll.EquivalenceClass diceOne, DiceRoll.EquivalenceClass diceTwo){
		for(AIMoveTreeDice item : aiMoveTreeRoot.getChildren()){
			if(item.getDiceValue() != diceOne || item.getDiceValue() != diceTwo) aiMoveTreeRoot.deleteChild(item);
		}
	}
	
	private void addDiceChildren(AIMoveTreeAbstract element){
		element.addChild(new AIMoveTreeDice(EquivalenceClass.ONE_OR_FIVE));
		element.addChild(new AIMoveTreeDice(EquivalenceClass.TWO));
		element.addChild(new AIMoveTreeDice(EquivalenceClass.THREE));
		element.addChild(new AIMoveTreeDice(EquivalenceClass.FOUR_OR_SIX));
	}
	
	private void addMoveChild(AIMoveTreeDice element, Player player, Piece piece, Position position){
		AIMoveTreeMove newMove = new AIMoveTreeMove( player, piece, position );
		element.addChild( newMove );
		addDiceChildren( newMove );		
	}
	
	private void buildTree(AIMoveTreeDice element){
		
		
	}
}
